using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UIElements;

public class BuildingManager : MonoBehaviour
{ 
    [SerializeField]
    private BuildingTypeSO buildingType;
    [SerializeField]
    private BuildingTypeListSO buildingTypeList;
    private bool isMouse = false;

    private void Start()
    {
        buildingType = buildingTypeList.list[0];
    }
    private void Update(){
        if(Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject() && !isMouse){//按下鼠标左键生成建筑(不在游戏对象之上)
            Instantiate(buildingType.prefab , GlobalScript.instance.GetMouseWorldPosition(), Quaternion.identity);
        }
    }


    public void ChooseMouse(){
        BuildingGhost.instance.Hide();
        isMouse = true;
    }
    public void ChooseBuilding1(){
        buildingType = buildingTypeList.list[0];
        BuildingGhost.instance.Show(buildingType.sprite);
        isMouse = false;
    }
    public void ChooseBuilding2(){
        buildingType = buildingTypeList.list[1];
        BuildingGhost.instance.Show(buildingType.sprite);
        isMouse = false;
    }
    public void ChooseBuilding3(){
        buildingType = buildingTypeList.list[2];
        BuildingGhost.instance.Show(buildingType.sprite);
        isMouse = false;
    }
}
